# _*_ coding : utf-8 _*_
# @Time : 2022/9/17 21:20
# @Author : Moonquake
# @File : Mail
# @Project : base.py
import time
import smtplib
from email.mime.text import MIMEText

content = input("请输入邮件内容: \n")
Subject = input("请输入邮件主题: \n")
sender_show = '****'
recipient_show = '****'
to_addrs = input("请输入目标邮箱: \n")
howmuch = int(input("请输入发送次数: \n"))
send_time = int(input("请输入时间间隔: \n(时间单位\秒)\n"))

user = 'solitariness@foxmail.com'
# 授权码
password ='orqwlooarpmacajg'
#设置邮件内容
msg = MIMEText(content)
# 主题提示
msg["Subject"] = Subject
# 发件人提示
msg["from"] = sender_show
# 收件人显示
msg["to"] = recipient_show
# 发送邮件
for i in range(1,howmuch+1):
    time.sleep(send_time)
    try:
        smtp = smtplib.SMTP_SSL("smtp.qq.com", 465)
        smtp.login(user, password)
        smtp.sendmail(user,to_addrs, msg.as_string())
    except(smtplib.SMTPException) as e:
        print(e.message)
    finally:
        smtp.quit()

print("已成功向指定邮箱发送所有邮件")
